package com.threadDemo;
import java.util.concurrent.CountDownLatch;

public class Producer implements Runnable{
    private final BoundedBuffer bb;
    private final CountDownLatch countDownLatch;

    Producer(BoundedBuffer bb, CountDownLatch countDownLatch){
        this.bb = bb;
        this.countDownLatch = countDownLatch;
    }
    @Override
    public void run() {
        try {
            double random = Math.random();
            System.out.println("开始生产数据="+random);
            bb.put(random);
            countDownLatch.countDown();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
